package com.androidhive.androidlistview;

import java.util.HashMap;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;
import android.support.v4.app.NavUtils;

public class VViewProfile extends Activity {
	SessionManager session;
	DatabaseHandler db=new DatabaseHandler(this);
	String VProfile=new String();
	String [] res=new String[]{};
	 public final static String NAME = "com.example.sample.MESSAGE";
	 public final static String CDET = "com.example.sample.MESSAGE";
	 public final static String CNU= "com.example.sample.MESSAGE";
	 public final static String EID = "com.example.sample.MESSAGE";
	 public final static String CADD = "com.example.sample.MESSAGE";
	 
	 String vNAME=new String();
	 String vDET=new String();
	 String vCNU=new String();
	 String vEID=new String();
	 
	 String cADD=new String();
	 

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_vview_profile);
		session = new SessionManager(getApplicationContext());
	    HashMap<String, String> user = session.getUserDetails();
	    String vendorId = (user.get(SessionManager.Vendor_Id)); 
      
		//TextView heading= (TextView)findViewById(R.id.textView6);
		
	    //textView6
		TextView name = (TextView)findViewById(R.id.textView8);
		TextView CDET = (TextView)findViewById(R.id.TextView01);
		TextView CNU = (TextView)findViewById(R.id.TextView02);
		TextView EID = (TextView)findViewById(R.id.TextView03);
		TextView cadd = (TextView)findViewById(R.id.TextView04);
		Log.d("Farmer",vendorId);
		VProfile=db.getVendorProfile(Integer.parseInt(vendorId));
		Log.d("Sucess","1");
		
		
		res=VProfile.split("#");
			vNAME=res[0];
			vDET=res[1];
			vCNU=res[2];
			Log.d("Sucess","2");
			vEID=res[3];
			cADD=res[4];
			Log.d("Sucess","3");
		//heading.setText("Welcome "+vNAME+"!!!!");
		name.setText(vNAME);
		CDET.setText(vDET);
		CNU.setText(vCNU);
		EID.setText(vEID);
		cadd.setText(cADD);
	
		
		
		// Show the Up button in the action bar.
	
	}
	public void editProfile(View view) {
		
		 Intent intent = new Intent(this, VEditProfile.class);
		   
		  
		 Log.d("in viewProfile","6");
		 
		   intent.putExtra(NAME, VProfile);
	    Log.d("in NAME",VProfile);
		 
//		    intent.putExtra(NAME, vNAME);
//		    Log.d("in NAME",vNAME);
//		    intent.putExtra(CDET, vCNU);
//		    Log.d("in CDET",vCNU);
//		    intent.putExtra(CNU, vEID);
//		    Log.d("in CNU",vEID);
//		    intent.putExtra(EID, vDET);
		  //  System.out.println("HareKrishna");
		    Log.d("MyApp","I am here");
		    startActivity(intent);
		    Log.d("Sucess","7");
		
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_fviewprofile, menu);
		return true;
	}

	
	

}
